﻿Imports System.ComponentModel
Imports Microsoft.Xna.Framework
Imports Runa.Foundation

Namespace Global.Runa.UI.Input

    Public MustInherit Class InputHandler
        Implements Runtime.IUpdateable
        Implements INotifyPropertyChanged

        Private m_UpdateOrder As Integer
        Private m_Enable As Boolean
        Private m_game As Game

        Public ReadOnly Property Game() As Game
            Get
                Return Me.m_game
            End Get
        End Property

        Public Event DataArraived(ByVal sender As Object, ByVal e As InputEventArgs)

        Public Event EnabledChanged(sender As Object, e As System.EventArgs) Implements Runtime.IUpdateable.EnabledChanged
        Public Event UpdateOrderChanged(sender As Object, e As System.EventArgs) Implements Runtime.IUpdateable.UpdateOrderChanged
        Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

        Public Property UpdateOrder() As Integer Implements Runtime.IUpdateable.UpdateOrder
            Get
                Return Me.m_UpdateOrder
            End Get
            Set(value As Integer)
                Me.m_UpdateOrder = value
                RaiseEvent UpdateOrderChanged(Me, Nothing)
            End Set
        End Property

        Public Property Enabled() As Boolean Implements Runtime.IUpdateable.Enabled
            Get
                Return Me.m_Enable
            End Get
            Set(value As Boolean)
                Me.m_Enable = value
                RaiseEvent EnabledChanged(Me, Nothing)
            End Set
        End Property

        Public Sub New(ByVal g As Game)
            Me.m_game = g
        End Sub

        Public MustOverride Sub Update(gameTime As Microsoft.Xna.Framework.GameTime) Implements Runtime.IUpdateable.Update

        Protected Sub OnDataArrived(ByVal sender As Object, ByVal e As InputEventArgs)
            RaiseEvent DataArraived(sender, e)
        End Sub

    End Class

End Namespace